-
Notifications
You must be signed in to change notification settings - Fork 628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix freelist corruption on tx.WriteTo #67
Conversation
Was causing freelist corruption on tx.WriteTo
Reliably triggers consistency check failures on ramdisk without freelist free fix.
Codecov Report
@@ Coverage Diff @@
## master #67 +/- ##
=========================================
Coverage ? 85.47%
=========================================
Files ? 9
Lines ? 1859
Branches ? 0
=========================================
Hits ? 1589
Misses ? 160
Partials ? 110
Continue to review full report at Codecov.
|
lgtm |
if ok { | ||
delete(f.allocs, p.id) | ||
} else if (p.flags & (freelistPageFlag | metaPageFlag)) != 0 { | ||
// Safe to claim txid as allocating since these types are private to txid. | ||
allocTxid = txid | ||
} else if (p.flags & freelistPageFlag) != 0 { | ||
// Freelist is always allocated by prior tx. | ||
allocTxid = txid - 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can fix the issue, but it's a little complicated. No need to handle freelist as a special case. I think it can be as simple as below.
$ git diff
diff --git a/freelist.go b/freelist.go
index fdf8a36..4a15832 100644
--- a/freelist.go
+++ b/freelist.go
@@ -118,9 +118,6 @@ func (f *freelist) free(txid common.Txid, p *common.Page) {
allocTxid, ok := f.allocs[p.Id()]
if ok {
delete(f.allocs, p.Id())
- } else if p.IsFreelistPage() {
- // Freelist is always allocated by prior tx.
- allocTxid = txid - 1
}
for id := p.Id(); id <= p.Id()+common.Pgid(p.Overflow()); id++ {
lol